.TH std::sub_match::operatorstring_type,std::sub_match::str 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::sub_match::operatorstring_type,std::sub_match::str \- std::sub_match::operatorstring_type,std::sub_match::str

.SH Synopsis
   operator string_type() const; \fB(1)\fP
   string_type str() const;      \fB(2)\fP

   Converts to an object of the underlying std::basic_string type.

   The first version is an implicit conversion, the second one is explicit.

.SH Parameters

   \fI(none)\fP

.SH Return value

   Returns the matched character sequence as an object of the underlying
   std::basic_string type. If the matched member is false, then the empty string is
   returned.

.SH Complexity

   Linear in the length of the underlying character sequence.

.SH Example


// Run this code

 #include <cassert>
 #include <iostream>
 #include <regex>
 #include <string>

 int main()
 {
     const std::string html{R"("<a href="https://cppreference.com/">)"};
     const std::regex re{"(http|https|ftp)://([a-z]+)\\\\.([a-z]{3})"};
     std::smatch parts;
     std::regex_search(html, parts, re);
     for (std::ssub_match const& sub : parts)
     {
         const std::string s = sub; // (1) implicit conversion
         assert(s == sub.str());    // (2)
         std::cout << s << '\\n';
     }
 }

.SH Output:

 https://cppreference.com
 https
 cppreference
 com
